package com.chen.pojo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
// @Component 等价于<bean id="user" class="com.chen.pojo.User"/>
//@Component 组件
@Component
@Scope("prototype")
public class User {
    private String name;
    private int age;

    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public User() {
    }

    public String getName() {
        return name;
    }
    //    属性注入
//    相当于<property name="name" value="小梁"/>
//    @Value("小梁")
    @Value("小红")
    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }
     @Value("25")
    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
